#include <stdio.h>

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int *twoSum(int *nums, int numsSize, int target, int *returnSize) {
    int *buf = (int *)malloc(sizeof(int) * 2);

    for (int i = 0; i < numsSize; i++)
        for (int j = i + 1; j < numsSize; j++)
            if (nums[i] + nums[j] == target) {
                return buf[0] = i, buf[1] = j, *returnSize = 2, buf;
            }
    return *returnSize = 0, buf;
}

int main(void) {
    printf("两数之和\n");
    int returnSize = 0;
    int nums[]     = {1, 2, 5, 7, 3};

    int *buf = twoSum(nums, sizeof(nums) / sizeof(int), 10, &returnSize);
    if (returnSize)
        printf("ans: %d, %d\n\n", buf[0], buf[1]);
    else
        printf("ans: None\n\n");
    return 0;
}